package com.gas.gm.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;

@Entity
public class Account implements Serializable{

	
	private static final long serialVersionUID = 1464051406212971356L;
	
	@Id
	private String systemId;
	
	private String password;
	
	private String companyNumber;
	
	private String companyAddress;
	
	@OneToOne(cascade=CascadeType.ALL, mappedBy="account")
	private Token token;

	public String getSystemId() {
		return systemId;
	}

	public void setSystemId(String systemId) {
		this.systemId = systemId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getCompanyNumber() {
		return companyNumber;
	}

	public void setCompanyNumber(String companyNumber) {
		this.companyNumber = companyNumber;
	}

	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}

	public Token getToken() {
		return token;
	}

	public void setToken(Token token) {
		this.token = token;
		token.setAccount(this);
	}
	
	public void removeToken(){
		this.token.setAccount(null);
		this.token=null;
	}

	@Override
	public String toString() {
		String toString="Account [systemId=" + systemId + ", password=" + password
		+ ", companyNumber=" + companyNumber + "]";
		if(this.token!=null)
			return toString + " token= "+token.getToken();
		else
			return toString;
	}
	
	
	

}
